package com.kunchi.platform.entity.project;

import com.kunchi.platform.entity.base.AbstractEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * Created by denniszhou on 2017/6/25.
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Entity
public class Project extends AbstractEntity<Long> {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private Long companyId;
    private String name;
    private String province;
    private String city;
    private Float latitude;
    private Float longitude;
    private String employer;
    private Date purchaseDate;
    private Date completionDate;
    private String contactName;
    private String customType;
    private String projectType;
    private String address;
    private Date installationDate;
    private String contactPhone;
    private String gateways;

    public List<String> getGateways() {
        try {
            return Arrays.asList(gateways.split(","));
        } catch (NullPointerException e) {
            return new ArrayList<>();
        }
    }

    public void setGateways(List<String> gateways) {
        try {
            this.gateways = String.join(",", gateways);
        } catch (NullPointerException e) {
            //
        }
    }
}
